//
//  GFNearResturtantViewController.m
//  GoodFood
//
//  Created by dllo on 15/10/28.
//  Copyright © 2015年 荣伟峰. All rights reserved.
//

#import "GFNearResturtantViewController.h"

@interface GFNearResturtantViewController ()<BMKLocationServiceDelegate, UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) BMKLocationService *locationService;//定位服务
@property (nonatomic, assign) double latitude;//纬度
@property (nonatomic, assign) double longitude;//经度
@property (nonatomic, strong) UITableView *conditionTableView;//选择条件tableView
@property (nonatomic, strong) UITableView *resturtantTableView;//餐厅列表的tableView
@property (nonatomic, strong) UIView *viewForSelect;//选择条件的视图
@property (nonatomic, strong) UIButton *buttonForDistance;//距离选择
@property (nonatomic, strong) UIButton *buttonForPrice;//人均花费选择
@property (nonatomic, strong) UIButton *buttonForCate;//菜系选择
@property (nonatomic, strong) NSArray *arrayForDistance;//距离数组
@property (nonatomic, strong) NSArray *arrayForPrice;//人均消费数组
@property (nonatomic, strong) NSArray *arrayForCate;//菜系数组
@property (nonatomic, assign) NSInteger whichIsTouch;//确认哪个button点击
@property (nonatomic, assign) BOOL firstLocation;//是否是第一次进入视图时候的定位判断
@property (nonatomic, assign) BOOL SelectOrClick;//判断是点击选择条件按钮还是上拉加载
@property (nonatomic, assign) NSInteger page;//页数
@property (nonatomic, copy) NSString *sessionId;//用户相关信息
@property (nonatomic, strong) NSMutableArray *arrayForResturtant;//餐厅列表数组
@property (nonatomic, strong) GFTouchView *touchView;//触摸视图
@property (nonatomic, assign) NSInteger allCount;//加载数据总数
@end

@implementation GFNearResturtantViewController
#pragma mark - 地图管理
- (void)managerMap {

    self.locationService = [[BMKLocationService alloc] init];
    [self.locationService startUserLocationService];
}
#pragma mark - 创建选择条件的view
- (void)creatViewForSelect {
    UIView *view = (UIView *)[self.navigationController.view viewWithTag:10001];
    self.viewForSelect = [[UIView alloc] initWithFrame:CGRectMake(0, view.frame.size.height, ScreenWidth, ScreenHeight / 20 )];
    [self.view addSubview:self.viewForSelect];
    self.viewForSelect.backgroundColor = [UIColor whiteColor];
    [self creatButtonForSelect];
}
#pragma mark - 创建选择条件的button
- (void)creatButtonForSelect {
    //距离选择button
    self.buttonForDistance = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.viewForSelect addSubview:self.buttonForDistance];
    [self.buttonForDistance setTitle:@"周边3公里" forState:0];
    [self.buttonForDistance setTintColor:[UIColor lightGrayColor]];
    self.buttonForDistance.frame = CGRectMake(5, 5, (ScreenWidth - 20) / 3, self.viewForSelect.frame.size.height - 10);
    self.buttonForDistance.layer.masksToBounds = YES;
    self.buttonForDistance.layer.borderWidth = 0.5;
    self.buttonForDistance.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [self.buttonForDistance addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    //人均消费选择button
    self.buttonForPrice = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.viewForSelect addSubview:self.buttonForPrice];
    [self.buttonForPrice setTitle:@"人均不限" forState:0];
    [self.buttonForPrice setTintColor:[UIColor lightGrayColor]];
    self.buttonForPrice.frame = CGRectMake(10 + (ScreenWidth - 20) / 3, 5, (ScreenWidth - 20) / 3, self.viewForSelect.frame.size.height - 10);
    self.buttonForPrice.layer.masksToBounds = YES;
    self.buttonForPrice.layer.borderWidth = 0.5;
    self.buttonForPrice.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [self.buttonForPrice addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    //菜系选择button
    self.buttonForCate = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.viewForSelect addSubview:self.buttonForCate];
    [self.buttonForCate setTitle:@"全部菜系" forState:0];
    [self.buttonForCate setTintColor:[UIColor lightGrayColor]];
    self.buttonForCate.frame = CGRectMake(15 + (ScreenWidth - 20) / 3 * 2, 5, (ScreenWidth - 20) / 3, self.viewForSelect.frame.size.height - 10);
    self.buttonForCate.layer.masksToBounds = YES;
    self.buttonForCate.layer.borderWidth = 0.5;
    self.buttonForCate.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [self.buttonForCate addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - button点击事件
- (void)button:(UIButton *)button {
    [self.view addSubview:self.touchView];
    [self.view addSubview:self.conditionTableView];
    UIView *view = (UIView *)[self.navigationController.view viewWithTag:10001];
    if (button == self.buttonForDistance) {
        self.whichIsTouch = 1;
        self.conditionTableView.frame = CGRectMake(0, view.frame.size.height + ScreenHeight / 20 - 5, ScreenWidth, 30 * self.arrayForDistance.count);

    } else if (button == self.buttonForPrice) {
        self.whichIsTouch = 2;
        self.conditionTableView.frame = CGRectMake(0, view.frame.size.height + ScreenHeight / 20 - 5, ScreenWidth, 30 * self.arrayForPrice.count);
    } else {
        self.whichIsTouch = 3;
        self.conditionTableView.frame = CGRectMake(0, view.frame.size.height + ScreenHeight / 20 - 5, ScreenWidth, 30 * self.arrayForCate.count);
    }
    [self.conditionTableView reloadData];
    [self animationForTableViewWithFrame:self.conditionTableView.frame];
}
#pragma mark - tableView出现动画
- (void)animationForTableViewWithFrame:(CGRect)frame {
    CAKeyframeAnimation *keyFrame = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    /* 2.设置path属性 */
    CGMutablePathRef path = CGPathCreateMutable();
    /* 设置path的起始位置 */
    CGPathMoveToPoint(path, NULL, self.conditionTableView.center.x, 0 - frame.origin.y );
    /* path添加路径的坐标点(直线) */
        CGPathAddLineToPoint(path, NULL,self.conditionTableView.center.x, frame.size.height);
    //    CGPathAddLineToPoint(path, NULL, 350, 300);
    keyFrame.path = path;
    /* 3.设置动画属性 */
    keyFrame.duration = 0.5;
    keyFrame.autoreverses = 0;
    keyFrame.repeatCount = 0;
    /* 4.layer添加动画 */
    [self.view bringSubviewToFront:self.viewForSelect];
    [self.conditionTableView.layer addAnimation:keyFrame forKey:@"keyFrame"];
}
#pragma mark - 条件数组数据
- (void)dataForArraySelect {
    self.app = [[UIApplication sharedApplication] delegate];
    self.sessionId = self.app.session_id;
    self.arrayForDistance = @[@"周边500米", @"周边1公里", @"周边2公里", @"周边3公里", @"周边5公里", @"周边10公里"];
    self.arrayForPrice = @[@"人均不限", @"50元以下", @"50~100元", @"100~200元", @"200元以上"];
    self.arrayForCate = @[@"全部菜系", @"江浙菜", @"川菜", @"海鲜", @"湘菜", @"火锅", @"烧烤"];
}
#pragma mark - 数据解析
- (void)handleData {
 
    NSString *url = [NSString stringWithFormat:@"http://api.meishixing.com/search/nearby/recommandplace/lng=%f&lat=%f&page=1&session_id=%@&distance=3000&food_category_name=&price=", self.longitude, self.latitude, self.sessionId];
//    NSLog(@"%@",url);
    
    [AFNetHandle GETWithURL:url body:nil httpHead:nil responseStyle:JSON success:^(id result) {
        
        self.arrayForResturtant = [NSMutableArray array];
        NSDictionary *dictionary = [NSDictionary dictionaryWithDictionary:result];
        NSArray *arr = [dictionary objectForKey:@"result"];
        for (NSDictionary *dic in arr) {
            GFNearResturtantModel *model = [GFNearResturtantModel modWithDic:dic];
            [self.arrayForResturtant addObject:model];
        }
        //        NSLog(@"%@",self.arrayForResturtant);
        if (self.arrayForResturtant.count != 0) {
            [self.resturtantTableView reloadData];

        }
        [self.waitView removeFromSuperview];
        [self.overTimeView removeFromSuperview];
        if (arr.count != 0) {
            if (self.arrayForResturtant.count < 20) {
                self.resturtantTableView.footer.hidden = YES;
            } else {
                self.resturtantTableView.footer.hidden = NO;
            }
        } else {
            self.resturtantTableView.footer.hidden = YES;
        }
    } fail:^(NSError *error) {
        [self.overTimeView removeFromSuperview];
        self.overTimeView = [[GFOverTimeView alloc] initWithFrame:self.view.frame withButtonBlock:^(UIButton *button) {
            [self.view addSubview:self.waitView];
            [self handleData];
        }];
        [self.waitView removeFromSuperview];
        [self.view addSubview:self.overTimeView];
     
    }];

}
#pragma mark - 条件选择的数据解析
- (void)handleDataForSelectDistance:(NSString *)distance withPrice:(NSString *)price withCate:(NSString *)cate {
    self.firstLocation = NO;
    self.locationService.delegate = self;
    [self.locationService startUserLocationService];
    if ([distance isEqualToString:@"周边500米"]) {
        distance = @"500";
    } else if ([distance isEqualToString:@"周边1公里"]) {
        distance = @"1000";
    } else if ([distance isEqualToString:@"周边2公里"]) {
        distance = @"2000";
    } else if ([distance isEqualToString:@"周边3公里"]) {
        distance = @"3000";
    } else if ([distance isEqualToString:@"周边5公里"]) {
        distance = @"5000";
    } else {
        distance = @"10000";
    }

    if ([price isEqualToString:@"人均不限"]) {
        price = @"";
    } else if ([price isEqualToString:@"50元以下"]) {
        price = @"0~50";
    } else if ([price isEqualToString:@"50~100元"]) {
        price = @"50~100";
    } else if ([price isEqualToString:@"100~200元"]) {
        price = @"100~200";
    } else {
        price = @"200~20000";
    }
    if ([cate isEqualToString:@"全部菜系"]) {
        cate = @"";
    }
    
    NSString *url = [NSString stringWithFormat:@"http://api.meishixing.com/search/nearby/recommandplace/lng=%f&lat=%f&page=%ld&session_id=%@&distance=%@&food_category_name=%@&price=%@", self.longitude, self.latitude, self.page, self.sessionId, distance, cate, price];
    NSLog(@"%f %f",self.latitude,self.longitude);
//    NSLog(@"%@",url);
    
    [AFNetHandle GETWithURL:url body:nil httpHead:nil responseStyle:JSON success:^(id result) {
        
        if (self.SelectOrClick) {
            self.arrayForResturtant = [NSMutableArray array];
        }
        
        NSDictionary *dictionary = [NSDictionary dictionaryWithDictionary:result];
        NSArray *arr = [dictionary objectForKey:@"result"];

        for (NSDictionary *dic in arr) {
            GFNearResturtantModel *model = [GFNearResturtantModel modWithDic:dic];
            [self.arrayForResturtant addObject:model];
        }
        NSLog(@"%ld",self.arrayForResturtant.count);

        [self.resturtantTableView reloadData];
        [self.waitView removeFromSuperview];
        [self.overTimeView removeFromSuperview];
        //        self.resturtantTableView.footer.hidden = YES;
        if (arr.count != 0) {
            if (self.arrayForResturtant.count < 20) {
                self.resturtantTableView.footer.hidden = YES;
            } else {
                self.resturtantTableView.footer.hidden = NO;
            }
        } else {
            self.resturtantTableView.footer.hidden = YES;
        }
    } fail:^(NSError *error) {
        [self.overTimeView removeFromSuperview];
        self.overTimeView = [[GFOverTimeView alloc] initWithFrame:self.view.frame withButtonBlock:^(UIButton *button) {
            [self.view addSubview:self.waitView];
            [self handleDataForSelectDistance:self.buttonForDistance.titleLabel.text withPrice:self.buttonForPrice.titleLabel.text withCate:self.buttonForCate.titleLabel.text];
        }];
        [self.waitView removeFromSuperview];
        [self.view addSubview:self.overTimeView];
    }];
    
}
#pragma mark - 导航
- (void)viewForNavi {
    UIView *view = (UIView *)[self.navigationController.view viewWithTag:10001];
    view.backgroundColor = [UIColor redColor];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth / 2, ScreenHeight / 3, ScreenWidth / 3, ScreenHeight / 4)];
    label.text = @"附近餐馆";
    label.textColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.7];
    label.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = label;
    self.view.backgroundColor = [UIColor lightGrayColor];
}
#pragma mark - 视图加载
- (void)viewDidLoad {
    [super viewDidLoad];
    self.firstLocation = YES;
    self.page = 1;
    [self dataForArraySelect];
    [self viewForNavi];
    [self managerMap];
    [self creatViewForSelect];
    [self creatTableView];
    [self creatTouchView];
    [self.view bringSubviewToFront:self.waitView];

    // Do any additional setup after loading the view.
}
#pragma mark - 视图将要出现
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.locationService.delegate = self;
    

}
#pragma mark - 视图将要消失
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.locationService.delegate = nil;
}
#pragma mark - 定位代理方法
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation {

//    CLLocationCoordinate2D test = CLLocationCoordinate2DMake(userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude);
    //转换 google地图、soso地图、aliyun地图、mapabc地图和amap地图所用坐标至百度坐标
//    NSDictionary* testdic = BMKConvertBaiduCoorFrom(test,BMK_COORDTYPE_GPS);
//    //转换GPS坐标至百度坐标
//    testdic = BMKConvertBaiduCoorFrom(test,BMK_COORDTYPE_GPS);
//    NSLog(@"x=%@,y=%@",[testdic objectForKey:@"x"],[testdic objectForKey:@"y"]);
//    //    CLLocationCoordinate2D pt = CLLocationCoordinate2DMake([[testdic objectForKey:@"x"] doubleValue], [[testdic objectForKey:@"y"] doubleValue]);
//    CLLocationCoordinate2D pt = BMKCoorDictionaryDecode(testdic);



    
    self.latitude = userLocation.location.coordinate.latitude;
    self.longitude = userLocation.location.coordinate.longitude;


    NSLog(@"ca%f,%f",self.latitude,self.longitude);
    if (self.latitude != 0 && self.longitude != 0) {
        [self.locationService stopUserLocationService];
        if (self.firstLocation) {

            [self handleData];
        }
    }



}
#pragma mark - 定位结束
- (void)didStopLocatingUser {
    self.locationService.delegate = nil;
}
#pragma mark - 创建tableView
- (void)creatTableView {
    UIView *view = (UIView *)[self.navigationController.view viewWithTag:10001];
    self.conditionTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, view.frame.size.height + ScreenHeight / 20, ScreenWidth, ScreenHeight - view.frame.size.height - ScreenHeight / 20) style:UITableViewStylePlain];
    self.conditionTableView.rowHeight = 30;
    self.conditionTableView.delegate = self;
    self.conditionTableView.dataSource = self;
    self.conditionTableView.layer.masksToBounds = YES;
    self.conditionTableView.layer.cornerRadius = 5;
    
    

    self.resturtantTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, ScreenHeight / 20, ScreenWidth, ScreenHeight - ScreenHeight / 20 ) style:UITableViewStylePlain];
    
    self.resturtantTableView.delegate = self;
    self.resturtantTableView.dataSource = self;
    self.resturtantTableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh:)];
    self.resturtantTableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footRefresh:)];
    self.resturtantTableView.footer.hidden = YES;
    self.resturtantTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.resturtantTableView registerClass:[GFNearResturtantTableViewCell class] forCellReuseIdentifier:@"resturtantList"];
    [self.view addSubview:self.resturtantTableView];
    [self.view bringSubviewToFront:self.viewForSelect];
}
#pragma mark - 下拉刷新
- (void)headerRefresh:(MJRefreshHeader *)header {
    [self.view addSubview:self.waitView];
    [self.resturtantTableView.header beginRefreshing];
    self.page = 1;
    self.SelectOrClick = YES;
    [self handleDataForSelectDistance:self.buttonForDistance.titleLabel.text withPrice:self.buttonForPrice.titleLabel.text withCate:self.buttonForCate.titleLabel.text ];

    [self.resturtantTableView.header endRefreshing];
}
#pragma mark - 上拉加载
- (void)footRefresh:(MJRefreshAutoNormalFooter *)footer {
    [self.view addSubview:self.waitView];
//    self.resturtantTableView.footer.hidden = NO;
    [self.resturtantTableView.footer beginRefreshing];
    self.page ++;
    self.SelectOrClick = NO;
    [self.resturtantTableView.footer endRefreshing];
    [self handleDataForSelectDistance:self.buttonForDistance.titleLabel.text withPrice:self.buttonForPrice.titleLabel.text withCate:self.buttonForCate.titleLabel.text ];


    
}
#pragma mark - tableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (tableView == self.resturtantTableView) {
        GFNearResturtantTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"resturtantList"];
        if (self.arrayForResturtant.count != 0) {
            GFNearResturtantModel *model = self.arrayForResturtant[indexPath.row];
            cell.model = model;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        } else {
            UITableViewCell *cellForNull = [tableView dequeueReusableCellWithIdentifier:@"null"];
            if (cellForNull == nil) {
                cellForNull = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"null"];
            }
            

            if (!self.firstLocation) {
                cellForNull.textLabel.text = @"您的附近没有推荐菜";
                cellForNull.textLabel.textAlignment = NSTextAlignmentCenter;
                cellForNull.textLabel.font = [UIFont systemFontOfSize:13];
                cellForNull.textLabel.textColor = [UIColor lightGrayColor];
                
            } else {
                cellForNull.textLabel.text = @"";
            }


            return cellForNull;
        }

        
    } else {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"select"];
        if (cell == nil) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"select"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        if (1 == self.whichIsTouch) {
            cell.textLabel.text = self.arrayForDistance[indexPath.row];
            [self cellForSelectWithCellText:cell withTouchType:self.whichIsTouch];
            
        } else if (2 == self.whichIsTouch) {
            cell.textLabel.text = self.arrayForPrice[indexPath.row];
            [self cellForSelectWithCellText:cell withTouchType:self.whichIsTouch];
        } else {
            cell.textLabel.text = self.arrayForCate[indexPath.row];
            [self cellForSelectWithCellText:cell withTouchType:self.whichIsTouch];
        }
        return cell;
    }

}
#pragma mark - cell是否是当前的选择条件
- (void)cellForSelectWithCellText:(UITableViewCell *)cell withTouchType:(NSInteger)touchType {
    switch (touchType) {
        case 1:
            if ([cell.textLabel.text isEqualToString:self.buttonForDistance.titleLabel.text]) {
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            } else {
                cell.accessoryType = UITableViewCellAccessoryNone;
            }
            break;
        case 2:
            if ([cell.textLabel.text isEqualToString:self.buttonForPrice.titleLabel.text]) {
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            } else {
                cell.accessoryType = UITableViewCellAccessoryNone;
            }
            break;
        case 3:
            if ([cell.textLabel.text isEqualToString:self.buttonForCate.titleLabel.text]) {
                cell.accessoryType = UITableViewCellAccessoryCheckmark;
            } else {
                cell.accessoryType = UITableViewCellAccessoryNone;
            }
            break;
    }
}
#pragma mark - 行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == self.resturtantTableView) {
        if (self.arrayForResturtant.count != 0) {
            return ScreenHeight / 5;
        } else {
            return self.resturtantTableView.frame.size.height;
        }
        
    } else {
        return 30;
    }
}

#pragma mark - row Number
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (tableView == self.resturtantTableView) {
        if (self.arrayForResturtant.count != 0) {
            return self.arrayForResturtant.count;
        } else {
            return 1;
        }
        
    } else {
        if (1 == self.whichIsTouch) {
            return self.arrayForDistance.count;
        } else if (2 == self.whichIsTouch) {
            return self.arrayForPrice.count;
        } else {
            return self.arrayForCate.count;
        }
    }

}
#pragma mark - cell 点击
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == self.conditionTableView) {
        [self.conditionTableView removeFromSuperview];
        if (1 == self.whichIsTouch) {
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            [self.buttonForDistance setTitle:cell.textLabel.text forState:0];
            self.buttonForDistance.titleLabel.text = cell.textLabel.text;
//            self.conditionTableView.frame = CGRectMake(0, 0, 0, 0);
            
        } else if (2 == self.whichIsTouch) {
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            [self.buttonForPrice setTitle:cell.textLabel.text forState:0];
            self.buttonForPrice.titleLabel.text = cell.textLabel.text;
//            self.conditionTableView.frame = CGRectMake(0, 0, 0, 0);
        } else {
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            [self.buttonForCate setTitle:cell.textLabel.text forState:0];
            self.buttonForCate.titleLabel.text = cell.textLabel.text;
//            self.conditionTableView.frame = CGRectMake(0, 0, 0, 0);
        }
        //根据选择的条件解析数据
        self.firstLocation = NO;
        [self.touchView removeFromSuperview];
        self.page = 1;
        self.SelectOrClick = YES;
        [self.view addSubview:self.waitView];
        [self handleDataForSelectDistance:self.buttonForDistance.titleLabel.text withPrice:self.buttonForPrice.titleLabel.text withCate:self.buttonForCate.titleLabel.text ];
    } else {
        if (self.arrayForResturtant.count != 0) {
            GFNearResturtantModel *model = [self.arrayForResturtant objectAtIndex:indexPath.row];
            GFResturtantDetialViewController *rdvc = [[GFResturtantDetialViewController alloc] initWithId:model.place_id withSession:self.sessionId];
            [self.navigationController pushViewController:rdvc animated:1];
        }

       
    }

}
#pragma mark - 选择条件tableView的view
- (void)creatTouchView {
    UIView *view = (UIView *)[self.navigationController.view viewWithTag:10001];
    self.touchView = [[GFTouchView alloc] initWithFrame:CGRectMake(0, view.frame.size.height + ScreenHeight / 20, ScreenWidth, ScreenHeight  - ScreenHeight / 20 - view.frame.size.height)];
    self.touchView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
    self.touchView.action = @selector(click:);
    self.touchView.target = self;
}
#pragma mark - touchView click
- (void)click:(GFTouchView *)view {
 
    [self.touchView removeFromSuperview];
    [self.conditionTableView removeFromSuperview];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
